package ar.com.cubika.trainees.view;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class TransportesServlet extends HttpServlet {

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doPost(request, response);
    }
    
    protected void setOperacionPermitida(
            String operacion, HttpServletRequest request, 
            HttpServletResponse response) {
        request.getSession().setAttribute("operacion permitida", operacion);
    }
    
    protected boolean checkOperacionPermitida(
            String operacion, HttpServletRequest request, 
            HttpServletResponse response) throws ServletException, IOException {
        boolean esta = operacion.equals(
                request.getSession().getAttribute("operacion permitida"));
        request.getSession().setAttribute("operacion permitida", null);
        if (!esta) {
            request.setAttribute("operacionDobleSubmit", operacion);
            request.getRequestDispatcher("/dobleSubmit.jsp").forward(
                    request, response);
        }
        return esta;
    }

}
